#include <iostream>
using namespace std;

// 已知
int n, a, b, c;
// 未知

int main()
{
    cin >> n >> a >> b >> c;
    n -= 3;
    do
    {
        if (a == b && b == c)
        {
            cout << "Yes" << endl;
            return 0;
        }
        a = b, b = c;
        cin >> c;
    } while (n--);
    cout << "No";
    return 0;
}